#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
ll n,m,t;
const ll N=1e5+5;
ll a[N];
ll aa[N];
ll c[N];
ll x[4];
string s[N];
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(ll i=1;i<=n;i++){
        cin>>aa[i];
    }
    for(ll i=1;i<=m;i++){
        cin>>c[i];
    }
    ll k=0;
    ll cur=1;
    while(1){
        if(cur>=n){
            break;
        }
        cur*=2;
        k++;
    }
    for(ll i=1;i<=k;i++){
        cin>>s[i];
    }
    cin>>t;
    while(t--){
        for(ll i=0;i<4;i++){
            cin>>x[i];
        }
        for(ll i=1;i<=n;i++){
            a[i]=aa[i]^x[i%4];
        }
        ll ans=0;
        for(ll i=1;i<=m;i++){
            
        }
    }
    return 0;
}